#include <stdio.h>
#include <stdlib.h>

#define min(a,b) (((a) < (b)) ? (a) : (b))

int main(int argc, char const *argv[])
{
    int length, count, *points, start, end, result = 0;
    scanf("%d%d", &length, &count);
    points = malloc(sizeof(int) * length);
    for (size_t i = 0; i <= length; i++)
    {
        points[i] = 0;
    }
    for (size_t i = 0; i < count; i++)
    {
        scanf("%d%d", &start, &end);
        for (size_t j = start; j <= min(end, length); j++)
        {
            points[j] = 1;
        }
    }
    for (size_t i = 0; i <= length; i++)
    {
        if (!points[i])
        {
            result++;
        }
    }
    printf("%d", result);
    return 0;
}
